<template>
    <div>
        <van-image
                width="100%"
                height="auto"
                :src="Url + goodsInfo.image"
        />
        <div class="goods-box">
            <div class="info">
                <div class="price">￥{{goodsInfo.price}}</div>
                <div class="title">{{goodsInfo.title}}</div>
                <div class="subtitle overF marGin">{{goodsInfo.subtitle?goodsInfo.subtitle:'无副标题'}}</div>
            </div>
            <div style="display: flex;align-items: center;justify-content: flex-end;">
                <div style="width: 100px;display: flex;align-items: center;justify-content: space-between;">
                    <div style="display: flex;align-items: center;width: 50px" @click="dzClick(goodsInfo.id)">
                        <template v-if="goodsInfo.dzstatus !== 0"><img style="width: 14px" width="14" height="14"
                                                                       src="../../assets/img/thumbsUp_active.png"/><span
                                style="margin-left: 3px">{{goodsInfo.dianzannumber?goodsInfo.dianzannumber:'点赞'}}</span>
                        </template>
                        <template v-if="goodsInfo.dzstatus === 0">
                            <img style="width: 14px" width="14" height="14"
                                 src="../../assets/img/thumbsUp.png"/><span style="margin-left: 3px">{{goodsInfo.dianzannumber?goodsInfo.dianzannumber:'点赞'}}</span>
                        </template>
                    </div>
                    <div style="margin-left: 15px;margin-top: 3px;width: 50px" @click="sheetClick"><img
                            style="width: 14px" width="14" height="14" src="../../assets/img/comment.png"/><span
                            style="margin-left: 3px">{{goodsInfo.commentnumber?goodsInfo.commentnumber:'评论'}}</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="userInfo-box" @click="navTo(business.userid)">
            <div style="font-size: 14px;padding: 10px 0;margin-left: 10px">作者</div>
            <div style="display: flex;align-items: start">
                <div style="width: 60px;height: 60px;">
                    <van-image
                            width="60"
                            height="60"
                            radius="60"
                            :src="Url + business.headpic"
                    >
                    </van-image>
                </div>
                <div class="userInfo-text">
                    <div class="nickname">{{business.nickname}}</div>
                    <div class="bio">{{business.bio}}</div>
                </div>
            </div>
        </div>
        <div class="goods-box" style="margin-top: 10px">
            <div class="info">
                <div class="s marGin">{{goodsInfo.intro?goodsInfo.intro:'无简介'}}</div>
            </div>
        </div>
        <!--<div class="kf">-->
        <!--<a href="tencent://message/?uin=798161989&Site=Sambow&Menu=yes">-->
        <!--<div>在&nbsp;线</div>-->
        <!--<div>客&nbsp;服</div>-->
        <!--</a>-->
        <!--</div>-->
        <template v-if="isBuy">
            <div style="background-color: #fff;width: 100%;display: flex;justify-content: center;padding: 30px 0">
                <div class="btn">等待解锁</div>
            </div>
        </template>
        <template v-if="!isBuy">
            <template v-if="goodsInfo.content">
                <div class="goods-box" style="margin-top: 10px;overflow: hidden">
                    <div v-html="goodsInfo.content"></div>
                    <div v-if="thumb.length != 0">
                        <template v-for="item in thumb">
                            <van-image
                                    width="100%"
                                    :src=" Url + item"
                            />
                        </template>
                    </div>
                </div>
            </template>
            <template v-else>
                <div class="goods-box" style="margin-top: 10px">
                    <div class="info">
                        <div class="s marGin">无详情</div>
                    </div>
                </div>
            </template>
        </template>
        <template v-if="isBuy">
            <!--<div style="width: 100%;display: flex;justify-content: center">-->
            <!--<div class="btn">等待解锁</div>-->
            <!--</div>-->
            <div class="buybtn">
                <div class="btngroup">
                    <div class="btn1" @click="pay(1)" :class="{ 'disable': isPay }">立即购买</div>
                </div>
            </div>
        </template>
        <!--<template v-if="!isBuy">-->
        <!--<div class="buybtn">-->
        <!--<div class="btngroup">-->
        <!--<div class="btn1" @click="download"  :class="{ 'disable': isPay }" >立即下载压缩包</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</template>-->
        <div style="width: 100%;height: 200px"></div>

        <van-action-sheet v-model="sheetShow" title="评论">
            <div class="content">
                <template v-for="(item,index) in commentList">
                    <div style="padding: 20px;border-bottom: 1px solid #eaeaea">
                        <div>
                            <div style="display: flex;align-items: center;">
                                <img style="width: 30px;height: 30px;border-radius: 50%"
                                     :src="Url + item.headpic"/>
                                <div style="margin-left: 10px;font-size: 14px">{{item.nickname}}</div>
                            </div>
                            <div style="margin: 10px 0 10px 40px;font-size: 15px">
                                <div>{{item.content}}</div>
                                <div style="font-size: 12px;color: #999;margin-top: 20px;">
                                    <div style="display: flex;align-items: center;justify-content: space-between;padding-bottom: 10px"
                                         :class="{ 'borderBottom': item.twocomment }">
                                        <div>{{item.createtime}}</div>
                                        <div>
                                            <div style="display: flex;align-items: center;justify-content: flex-end;">
                                                <div style="width: 80px;display: flex;align-items: center;justify-content: space-between;">
                                                    <div style="display: flex;align-items: center;width: 40px"
                                                         @click="dzplClick(item.id,index,1)">
                                                        <template v-if="item.dzstatus !== 0"><img style="width: 14px"
                                                                                                  width="14" height="14"
                                                                                                  src="../../assets/img/thumbsUp_active.png"/><span
                                                                style="margin-left: 3px">{{item.dianzannumber?item.dianzannumber:'0'}}</span>
                                                        </template>
                                                        <template v-if="item.dzstatus === 0">
                                                            <img style="width: 14px" width="14" height="14"
                                                                 src="../../assets/img/thumbsUp.png"/><span
                                                                style="margin-left: 3px">{{item.dianzannumber?item.dianzannumber:'0'}}</span>
                                                        </template>
                                                    </div>
                                                    <div style="margin-left: 15px;margin-top: 3px;width: 40px"
                                                         @click="wcommentClick(item.id)"><img
                                                            style="width: 14px" width="14" height="14"
                                                            src="../../assets/img/comment.png"/><span
                                                            style="margin-left: 3px">{{item.commentnumber}}</span></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <template v-if="item.twocomment">
                                        <div style="padding: 20px 0 20px 20px;">
                                            <div>
                                                <div style="display: flex;align-items: center;">
                                                    <img style="width: 30px;height: 30px;border-radius: 50%"
                                                         :src="Url + item.twocomment.headpic" alt="">
                                                    <div style="margin-left: 10px;font-size: 14px">
                                                        {{item.twocomment.nickname}}
                                                    </div>
                                                </div>
                                                <div style="margin: 10px 0 10px 40px;font-size: 15px">
                                                    <div>{{item.twocomment.content}}</div>
                                                    <div style="font-size: 12px;color: #999;margin-top: 20px;display: flex;align-items: center;justify-content: space-between">
                                                        <div>{{item.twocomment.createtime}}</div>
                                                        <div>
                                                            <div style="display: flex;align-items: center;justify-content: flex-end;">
                                                                <div style="width: 80px;display: flex;align-items: center;justify-content: space-between;">
                                                                    <div style="display: flex;align-items: center;width: 40px"
                                                                         @click="dzplClick(item.twocomment.id,index,2)">
                                                                        <template v-if="item.twocomment.dzstatus !== 0">
                                                                            <img style="width: 14px" width="14"
                                                                                 height="14"
                                                                                 src="../../assets/img/thumbsUp_active.png"/><span
                                                                                style="margin-left: 3px">{{item.twocomment.dianzannumber?item.twocomment.dianzannumber:'0'}}</span>
                                                                        </template>
                                                                        <template v-if="item.twocomment.dzstatus === 0">
                                                                            <img style="width: 14px" width="14"
                                                                                 height="14"
                                                                                 src="../../assets/img/thumbsUp.png"/><span
                                                                                style="margin-left: 3px">{{item.twocomment.dianzannumber?item.twocomment.dianzannumber:'0'}}</span>
                                                                        </template>
                                                                    </div>
                                                                    <div style="margin-left: 15px;margin-top: 3px;width: 40px"
                                                                         @click="wcommentClick(item.id)"><img
                                                                            style="width: 14px" width="14" height="14"
                                                                            src="../../assets/img/comment.png"/><span
                                                                            style="margin-left: 3px"></span></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                            <div style="color: rgb(86,12,149);display: flex;align-items: center;margin-bottom: 3px"  v-if="item.commentnumber >= 2" @click="sheetShowsClick(item.id)">
                                                <div>查看全部{{item.commentnumber}}回复</div>
                                                <van-icon name="arrow"/>
                                            </div>
                                        </div>

                                    </template>
                                </div>
                            </div>

                        </div>
                    </div>
                </template>
                <div style="width: 100%;height: 54px;position: fixed;bottom: 0;display: flex;justify-content: center;margin-top: 10px">
                    <div style="width: 94%;background-color: #f7f7f7;height: 54px;border-radius: 10px;color: #b3b3b3;font-size: 14px;display: flex;align-items: center;padding-left: 30px"
                         @click="pid = '',sheetShow = !sheetShow,wSheetShow =!wSheetShow">写下你的评论...
                    </div>
                </div>
            </div>
        </van-action-sheet>
        <van-action-sheet v-model="wSheetShow" title="写下你的评论...">
            <div class="content2">
                <van-field
                        v-model="message"
                        rows="5"
                        autosize
                        type="textarea"
                        maxlength="100"
                        placeholder="写下你的评论"
                        show-word-limit
                />
                <div style="display: flex;justify-content: end;margin-right: 10px">
                    <van-button style="width: 100px;margin: 5px 0;background-color: #f7f7f7;height: 34px" round
                                :disabled="message === ''" type="default" @click="addComment">发送
                    </van-button>
                </div>
            </div>
        </van-action-sheet>
        <van-action-sheet v-model="sheetShows" title="评论详情">
            <div class="content">
                <div style="padding: 20px;border-bottom: 1px solid #eaeaea">
                    <div>
                        <div style="display: flex;align-items: center;">
                            <img style="width: 30px;height: 30px;border-radius: 50%"
                                 :src="Url + topdata.headpic"/>
                            <div style="margin-left: 10px;font-size: 14px">{{topdata.nickname}}</div>
                        </div>
                        <div style="margin: 10px 0 10px 40px;font-size: 15px">
                            <div>{{topdata.content}}</div>
                            <div style="font-size: 12px;color: #999;margin-top: 20px;">
                                <div style="display: flex;align-items: center;justify-content: space-between;padding-bottom: 10px"
                                     :class="{ 'borderBottom': topdata.twocomment }">
                                    <div>{{topdata.createtime}}</div>
                                    <div>
                                        <div style="display: flex;align-items: center;justify-content: flex-end;">
                                            <div style="width: 80px;display: flex;align-items: center;justify-content: space-between;">
                                                <div style="display: flex;align-items: center;width: 40px"
                                                     @click="dzplClick(topdata.id,index,3)">
                                                    <template v-if="topdata.dzstatus !== 0"><img style="width: 14px"
                                                                                              width="14" height="14"
                                                                                              src="../../assets/img/thumbsUp_active.png"/><span
                                                            style="margin-left: 3px">{{topdata.dianzannumber?topdata.dianzannumber:'0'}}</span>
                                                    </template>
                                                    <template v-if="topdata.dzstatus === 0">
                                                        <img style="width: 14px" width="14" height="14"
                                                             src="../../assets/img/thumbsUp.png"/><span
                                                            style="margin-left: 3px">{{topdata.dianzannumber?topdata.dianzannumber:'0'}}</span>
                                                    </template>
                                                </div>
                                                <div style="margin-left: 15px;margin-top: 3px;width: 40px"
                                                     @click="wcommentClick(topdata.id)"><img
                                                        style="width: 14px" width="14" height="14"
                                                        src="../../assets/img/comment.png"/><span
                                                        style="margin-left: 3px">{{topdata.commentnumber}}</span></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <template v-for="(item,index) in commentLists">
                        <div style="padding: 20px 0 20px 20px;border-bottom: 1px solid #eaeaea">
                            <div>
                                <div style="display: flex;align-items: center;">
                                    <img style="width: 30px;height: 30px;border-radius: 50%"
                                         :src="Url + item.headpic"/>
                                    <div style="margin-left: 10px;font-size: 14px">{{item.nickname}}</div>
                                </div>
                                <div style="margin: 10px 0 10px 40px;font-size: 15px">
                                    <div>{{item.content}}</div>
                                    <div style="font-size: 12px;color: #999;margin-top: 20px;">
                                        <div style="display: flex;align-items: center;justify-content: space-between;padding-bottom: 10px"
                                             :class="{ 'borderBottom': item.twocomment }">
                                            <div>{{item.createtime}}</div>
                                            <div>
                                                <div style="display: flex;align-items: center;justify-content: flex-end;">
                                                    <div style="width: 80px;display: flex;align-items: center;justify-content: space-between;">
                                                        <div style="display: flex;align-items: center;width: 40px"
                                                             @click="dzplClick(item.id,index,4)">
                                                            <template v-if="item.dzstatus !== 0"><img
                                                                    style="width: 14px" width="14" height="14"
                                                                    src="../../assets/img/thumbsUp_active.png"/><span
                                                                    style="margin-left: 3px">{{item.dianzannumber?item.dianzannumber:'0'}}</span>
                                                            </template>
                                                            <template v-if="item.dzstatus === 0">
                                                                <img style="width: 14px" width="14" height="14"
                                                                     src="../../assets/img/thumbsUp.png"/><span
                                                                    style="margin-left: 3px">{{item.dianzannumber?item.dianzannumber:'0'}}</span>
                                                            </template>
                                                        </div>
                                                        <div style="margin-left: 15px;margin-top: 3px;width: 40px"
                                                             @click="wcommentClick(topdata.id)"><img
                                                                style="width: 14px" width="14" height="14"
                                                                src="../../assets/img/comment.png"/><span
                                                                style="margin-left: 3px">{{item.commentnumber}}</span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <template v-if="item.twocomment">
                                            <div style="padding: 20px 0 20px 20px;">
                                                <div>
                                                    <div style="display: flex;align-items: center;">
                                                        <img style="width: 30px;height: 30px;border-radius: 50%"
                                                             :src="Url + item.twocomment.headpic" alt="">
                                                        <div style="margin-left: 10px;font-size: 14px">
                                                            {{item.twocomment.nickname}}
                                                        </div>
                                                    </div>
                                                    <div style="margin: 10px 0 10px 40px;font-size: 15px">
                                                        <div>{{item.twocomment.content}}</div>
                                                        <div style="font-size: 12px;color: #999;margin-top: 20px;display: flex;align-items: center;justify-content: space-between">
                                                            <div>{{item.twocomment.createtime}}</div>
                                                            <div>
                                                                <div style="display: flex;align-items: center;justify-content: flex-end;">
                                                                    <div style="width: 80px;display: flex;align-items: center;justify-content: space-between;">
                                                                        <div style="display: flex;align-items: center;width: 40px"
                                                                             @click="dzplClick(item.twocomment.id,index,5)">
                                                                            <template
                                                                                    v-if="item.twocomment.dzstatus !== 0">
                                                                                <img style="width: 14px" width="14"
                                                                                     height="14"
                                                                                     src="../../assets/img/thumbsUp_active.png"/><span
                                                                                    style="margin-left: 3px">{{item.twocomment.dianzannumber?item.twocomment.dianzannumber:'0'}}</span>
                                                                            </template>
                                                                            <template
                                                                                    v-if="item.twocomment.dzstatus === 0">
                                                                                <img style="width: 14px" width="14"
                                                                                     height="14"
                                                                                     src="../../assets/img/thumbsUp.png"/><span
                                                                                    style="margin-left: 3px">{{item.twocomment.dianzannumber?item.twocomment.dianzannumber:'0'}}</span>
                                                                            </template>
                                                                        </div>
                                                                        <div style="margin-left: 15px;margin-top: 3px;width: 40px"
                                                                             @click="wcommentClick(item.id)"><img
                                                                                style="width: 14px" width="14"
                                                                                height="14"
                                                                                src="../../assets/img/comment.png"/><span
                                                                                style="margin-left: 3px"></span></div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>

                                                </div>
                                                <div style="color: rgb(86,12,149);display: flex;align-items: center;margin-bottom: 3px">
                                                    <div>查看全部{{item.commentnumber}}回复</div>
                                                    <van-icon name="arrow"/>
                                                </div>
                                            </div>

                                        </template>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </template>
                    <div style="width: 100%;height: 54px;position: fixed;bottom: 0;display: flex;justify-content: center;margin-top: 10px">
                        <div style="width: 94%;background-color: #f7f7f7;height: 54px;border-radius: 10px;color: #b3b3b3;font-size: 14px;display: flex;align-items: center;padding-left: 30px"
                             @click="pid = '',sheetShow = !sheetShow,wSheetShow =!wSheetShow">写下你的评论...
                        </div>
                    </div>
                </div>
            </div>
        </van-action-sheet>
    </div>
</template>

<script>
    export default {
        name: "goodsDetails",
        data() {
            return {
                uri: '',
                message: '',
                id: null,
                isPay: false,
                isBuy: false,
                wSheetShow: false,
                sheetShow: false,
                sheetShows: false,
                goodsInfo: {},
                business: {},
                thumb: [],
                commentList: [],
                commentLists: [],
                topdata: {},
                pid: '',
                isBottom: ''
            }
        },
        created() {
            this.id = this.$route.params.id;
            this.uri = this.Url;
            this.getDetails(this.$route.params.id);
        },
        watch: {
            wSheetShow(val) {
                if (!val) {
                    this.message = '';
                }
            }
        },
        methods: {
            /* 查看全部评论 */
            sheetShowsClick(id) {
                this.sheetShow = false;
                this.sheetShows = true;

                let that = this;
                that.request1.post1({
                    url: that.Url + "/api/goods/commentdetail",
                    params: {commentid: id,},
                    success: function (res) {
                        if (res.data.code == 1) {
                            that.topdata = res.data.data.topdata;
                            console.log(res.data.data);
                            that.commentLists = res.data.data.twolist.data;

                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            wcommentClick(id) {
                this.pid = id;
                this.SheetShow = false;
                this.wSheetShow = !this.wSheetShow;
                console.log(this.pid);
            },
            /* 添加评论 */
            addComment() {
                let that = this;
                that.request1.post1({
                    url: that.Url + "/api/goods/commentsave",
                    params: {goodsid: that.goodsInfo.id, content: that.message, pid: that.pid},
                    success: function (res) {
                        if (res.data.code == 1) {
                            that.$toast.success('评论成功');
                            that.getComment(that.goodsInfo.id);
                            that.goodsInfo.commentnumber++;
                            that.SheetShow = false;
                            that.wSheetShow = false;
                            that.sheetShows = false;
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            /* 处理评论 */
            sheetClick() {
                if (this.goodsInfo.commentnumber < 1) return this.wSheetShow = true;
                this.sheetShow = !this.sheetShow;
            },
            /* 获取评论列表 */
            getComment(id) {
                let that = this;
                that.request1.post1({
                    url: that.Url + "/api/goods/comments",
                    params: {goodsid: id, page: 1},
                    success: function (res) {
                        if (res.data.code == 1) {
                            that.commentList = res.data.data.list.data;
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            /* 点赞或取消点赞 */
            dzClick(id) {
                let that = this;
                that.request1.post1({
                    url: that.Url + "api/goods/dianzansave",
                    params: {goodsid: id},
                    success: function (res) {
                        if (res.data.code == 1) {
                            if (that.goodsInfo.dzstatus === 0) {
                                that.$toast('点赞成功');
                                that.goodsInfo.dianzannumber++;
                            } else {
                                that.$toast('取消点赞');
                                that.goodsInfo.dianzannumber--;
                            }
                            that.goodsInfo.dzstatus === 1 ? that.goodsInfo.dzstatus = 0 : that.goodsInfo.dzstatus = 1;
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            /* 给评论点赞或取消点赞 */
            dzplClick(id, index, type) {
                let that = this;
                that.request1.post1({
                    url: that.Url + "api/goods/comdianzansave",
                    params: {commentid: id},
                    success: function (res) {
                        if (res.data.code == 1) {
                            if (type === 1) {
                                console.log('进了此处没');
                                if (that.commentList[index].dzstatus === 0) {
                                    that.$toast('点赞成功');
                                    that.commentList[index].dianzannumber++;
                                } else {
                                    that.$toast('取消点赞');
                                    that.commentList[index].dianzannumber--;
                                }
                                that.commentList[index].dzstatus === 1 ? that.commentList[index].dzstatus = 0 : that.commentList[index].dzstatus = 1;
                            } else if(type === 2) {
                                if (that.commentList[index].twocomment.dzstatus === 0) {
                                    that.$toast('点赞成功');
                                    that.commentList[index].twocomment.dianzannumber++;
                                } else {
                                    that.$toast('取消点赞');
                                    that.commentList[index].twocomment.dianzannumber--;
                                }
                                that.commentList[index].twocomment.dzstatus === 1 ? that.commentList[index].twocomment.dzstatus = 0 : that.commentList[index].twocomment.dzstatus = 1;
                            }else if (type === 3){
                                if (that.topdata.dzstatus === 0) {
                                    that.$toast('点赞成功');
                                    that.topdata.dianzannumber++;
                                } else {
                                    that.$toast('取消点赞');
                                    that.topdata.dianzannumber--;
                                }
                                that.topdata.dzstatus === 1 ? that.topdata.dzstatus = 0 : that.topdata.dzstatus = 1;
                            }else if(type === 4){
                                if (that.commentLists[index].dzstatus === 0) {
                                    that.$toast('点赞成功');
                                    that.commentLists[index].dianzannumber++;
                                } else {
                                    that.$toast('取消点赞');
                                    that.commentLists[index].dianzannumber--;
                                }
                                that.commentLists[index].dzstatus === 1 ? that.commentLists[index].dzstatus = 0 : that.commentLists[index].dzstatus = 1;
                            }
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            navTokf() {
                this.$router.push('/CustomerService/CustomerService');
            },
            /* 跳转到商家详情页 */
            navTo(id) {
                this.$router.push('/goods/BusinessInfo/' + id);
            },
            getDetails(id) {
                let that = this;
                that.request1.post1({
                    url: that.Url + "api/goods/detail",
                    params: {goodsid: id},
                    success: function (res) {
                        if (res.data.code == 1) {
                            that.goodsInfo = res.data.data.goods;
                            if (res.data.data.goods.commentnumber > 0) {
                                that.getComment(res.data.data.goods.id);
                            }
                            that.business = res.data.data.business;
                            that.isBuy = res.data.data.isbuy == 0 ? true : false;
                            that.thumb = res.data.data.goods.thumb.split(',');
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                });
            },
            /* 点击下载 */
            download() {
                window.location.href = this.Url + this.goodsInfo.downfiles;
            },
            pay() {
                let that = this;
                var ua = navigator.userAgent.toLowerCase();//获取判断用的对象
                if (that.isPay) return this.$toast('支付排队中...');
                that.isPay = true;
                var paymethod = 1;
                if (ua.match(/MicroMessenger/i) == "micromessenger") {
                    //微信浏览器打开
                    paymethod = 1;
                } else {
                    //h5打开
                    paymethod = 2;
                }
                //微信支付
                that.request1.post1({
                    url: that.Url + "api/goods/addOrder",
                    params: {goodsid: that.id},
                    success: function (res) {
                        if (res.data.code == 1) {
                            var ress = JSON.parse(res.data.data);
                            if (paymethod == 1) {
                                WeixinJSBridge.invoke(
                                    'getBrandWCPayRequest', {
                                        "appId": ress.appId,     //公众号名称，由商户传入
                                        "timeStamp": ress.timeStamp,         //时间戳，自1970年以来的秒数
                                        "nonceStr": ress.nonceStr, //随机串
                                        "package": ress.package,
                                        "signType": ress.signType,         //微信签名方式：
                                        "paySign": ress.paySign //微信签名
                                    },
                                    function (res) {
                                        //console.log(res);
                                        // that.isPay = false;
                                        if (res.err_msg == "get_brand_wcpay_request:ok") {
                                            that.$toast.success({
                                                message: '支付成功',
                                                duration: 1000,
                                                onClose: () => {
                                                    that.isBuy = false;
                                                }
                                            });
                                            that.isPay = false;

                                        } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                                            that.$toast("支付取消");
                                            that.isPay = false;
                                        } else {
                                            that.$toast("支付失败");
                                            that.isPay = false;
                                        }
                                        timer = setTimeout(function () {
                                            that.isPay = false;
                                        }, 2000)
                                    }
                                );
                            } else {
                                that.$axios.post(that.Url + 'api/user.index/third', {}
                                ).then(function (res) {
                                    that.isPay = false;
                                    console.log(res);
                                    if (res.data.code == 1) {

                                    }
                                }).catch(function (error) {
                                    console.log(error)
                                });
                            }
                        } else {
                            alert("支付失败")
                            that.isPay = false;
                        }
                    },
                    fail: function (error) {
                        alert("支付失败")
                        that.isPay = false;

                    }
                })
            }
        }
    }
</script>

<style scoped>

    .borderBottom {
        border-bottom: 1px solid #eaeaea;
    }

    .userInfo-box {
        background-color: #ffffff;
        padding: 20px;
        padding-top: 0;
        margin: 10px 5px;
    }

    .content {
        min-height: 300px;
        position: relative;
    }

    .userInfo-text {
        margin-left: 10px;
    }

    .nickname {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 10px;
    }

    .bio {
        font-size: 14px;
        color: rgb(242, 215, 183);
        width: 250px;
    }

    .kf {
        position: fixed;
        bottom: 200px;
        right: 10%;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        color: #ffffff;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background-color: #fa3d4b;
    }

    .goods-box {
        display: flex;
        flex-direction: column;
        background-color: #ffffff;
        padding: 10px 10px;
        color: #333;
    }

    .goods-box img {
        width: 100%;
    }

    .info {
        margin-left: 10px;
    }

    .title {
        font-size: 15px;
        font-weight: bold;
    }

    .btn {
        width: 228px;
        height: 32px;
        line-height: 32px;
        text-align: center;
        font-size: 14px;
        background: #fff0f0;
        border: 1px solid #e0c0c3;
        color: #c66c6e;
        border-radius: 16px;
    }

    .subtitle {
        font-size: 14px;
    }

    .marGin {
        margin: 5px 0;
    }

    .widthOver {
        width: 190px;
    }

    .overF {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .s {
        color: #999;
    }

    .price {
        font-size: 24px;
        font-weight: bold;
        display: flex;
        color: rgba(255, 93, 49, 0.87);
    }

    .buybtn {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        min-height: 76px;
        background: rgba(255, 255, 255, 0.9);
        box-sizing: border-box;
        padding: 10px 20px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    .buybtn .btngroup {
        width: 100%;
        /*height: 76px;*/
        display: flex;
        justify-content: space-between;
    }

    .buybtn .btngroup div {
        width: 48%;
        height: 39px;
        text-align: center;
        line-height: 39px;
        color: #fff;
        font-size: 14px;
        border-radius: 5px;
        flex: 1;
    }

    .buybtn .btngroup div:nth-child(2) {
        margin-left: .2rem;
    }

    .buybtn .btn1 {
        background: #27aa2a;
    }

    .buybtn .btn2 {
        background: #4483e4;
    }

    .buybtn .disable {
        background: #999999;
    }

    .buybtn .hascount {
        /*position: absolute;*/
        /*bottom: 0;*/
        /*left: 0;*/
        width: 100%;
        font-size: 12px;
        height: 24px;
        line-height: 24px;
        color: #fc5d4d;
        display: block;
        text-align: center;
    }

    .buybtn .hascount span {
        text-decoration: line-through;
    }
</style>